package books.ThinkingInJava.src.Chapter18;

import books.ThinkingInJava.src.Tools.Output;

import java.io.*;

/**
 * @author bloodcolding
 * @since 12/27/2018 5:11 PM
 */
public class TestReader {
    public static void main(String[] arg) throws IOException {
        StringReader stringReader =
                new StringReader(BufferedInputFile.read(new File("D:\\Doc" +
                        "\\Test\\1.txt")));
        int c;
        while ((c = stringReader.read()) != -1) {
//            Output.println((char)c);
        }
        stringReader.close();

        DataInputStream dataInputStream =
                new DataInputStream(new ByteArrayInputStream(BufferedInputFile.read(new File("D:\\Doc\\Test\\1.txt")).getBytes()));
//        try {
//            while (true) {
//                Output.println((char) dataInputStream.readByte());
//            }
//        } catch (IOException ioe) {
//            Output.println("End of stream.");  //没有hasNext()方法
//        }

        try {
            while (dataInputStream.available() != 0) {
                Output.println((char) dataInputStream.readByte());
            }
        } catch (IOException ie) {
            ie.printStackTrace();
        }

    }
}

